from util.ObjectMap import *
from util.ParseConfiurationFile import ParseConfigFile

class HomePage:
    def __init__(self,driver):
        self.driver = driver
        self.parseCF = ParseConfigFile()

    def addressLink(self):
        try:
            locateType, locatorExpression = self.parseCF.getOptionValue("126mail_homePage","homePage.addressBook").split(">")
            elementObj = getElements(self.driver,locateType,locatorExpression)
            return elementObj[0]
        except Exception as e:
            raise e

if __name__ == '__main__':
    from selenium import webdriver
    import time
    from appModules.LoginAction import LoginAction
    driver = webdriver.Chrome()
    driver.get("http://mail.126.com/")
    LoginAction.login(driver,"wyu0430","19870303")
    homepage = HomePage(driver)
    time.sleep(3)
    elementObj= homepage.addressLink()
    elementObj.click()
    time.sleep(5)
    driver.quit()
